package com.example.teaching_server.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;

/**
 * 课程分类实体类
 * 管理课程的分类信息
 */
@Getter
@Setter
@ToString
@EqualsAndHashCode(of = "id")
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "course_categories", indexes = {
        @Index(name = "idx_category_type", columnList = "category_type"),
        @Index(name = "idx_display_order", columnList = "display_order")
})
public class Category {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(nullable = false)
    @NotBlank(message = "分类名称不能为空")
    private String name;

    private String icon;

    @Column(name = "category_type", nullable = false)
    @NotBlank(message = "分类类型不能为空")
    private String categoryType;

    @Column(name = "display_order")
    @Builder.Default
    private Integer displayOrder = 0;

    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;

}
